IF(ROSS_BUILD_DOXYGEN)

IF(DOXYGEN_DOT_FOUND)
  SET(HAVE_DOT YES)

  OPTION(DOXYGEN_CALL_GRAPHS "Build Doxygen Call Graphs" OFF)
  IF(DOXYGEN_CALL_GRAPHS)
    SET(CALL_GRAPHS_ON YES)
  ELSE(DOXYGEN_CALL_GRAPHS)
    SET(CALL_GRAPHS_ON NO)
  ENDIF(DOXYGEN_CALL_GRAPHS)

  OPTION(DOXYGEN_CALLER_GRAPHS "Build Doxygen Caller Graphs" OFF)
  IF(DOXYGEN_CALLER_GRAPHS)
    SET(CALLER_GRAPHS_ON YES)
  ELSE(DOXYGEN_CALLER_GRAPHS)
    SET(CALLER_GRAPHS_ON NO)
  ENDIF(DOXYGEN_CALLER_GRAPHS)

  OPTION(DOXYGEN_DEFAULT_GRAPHS "Build Default Doxygen Graphs" OFF)
  IF(DOXYGEN_DEFAULT_GRAPHS)
    SET(DEFAULT_GRAPHS_ON YES)
  ELSE(DOXYGEN_DEFAULT_GRAPHS)
    SET(DEFAULT_GRAPHS_ON NO)
  ENDIF(DOXYGEN_DEFAULT_GRAPHS)

ELSE(DOXYGEN_DOT_FOUND)
  SET(HAVE_DOT NO)
  SET(CALL_GRAPHS NO)
  SET(CALLER_GRAPHS NO)
  SET(DEFAULT_GRAPHS NO)
ENDIF(DOXYGEN_DOT_FOUND)

SET(DOXYGEN_OUTPUT ${CMAKE_BINARY_DIR}/docs/html/index.html)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.user.in ${CMAKE_BINARY_DIR}/Doxyfile.user)

ADD_CUSTOM_COMMAND(
  OUTPUT ${DOXYGEN_OUTPUT}
  COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
  COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile.user
  COMMAND ${CMAKE_COMMAND} -E echo "Done.")

ADD_CUSTOM_TARGET(apidoc ALL DEPENDS ${DOXYGEN_OUTPUT})

ENDIF(ROSS_BUILD_DOXYGEN)
